
#include <cassert>
#include <iostream>
#include <string>
using namespace std;

/**
 * @brief 不使用虚函数不会产生多态的效果
 * 使用函数指针吧,函数指针没有虚函数表
 */

class Base {
protected:
  int a, b;

public:
  Base(int v) : a{v} {}
  Base() = default;
  virtual void pnt() { cout << a << " base\n"; }
  void plus(int &c) { ++c; }
  void operator()(const string str) { cout << str << endl; }
};

class Derive : public Base {
public:
  int a, c;

public:
  Derive(int v) : a{v} {}
  Derive() = default;
  void pnt() { cout << a << b << " derive\n"; }
  ~Derive(){};
};

void pnt(Base &bs) { bs.pnt(); }

int main() {
  Base b;
  Derive d;
  b = d;
  b.pnt();
  Base *bptr = new Derive;
  bptr->pnt();
  // bptr->()("myname");

  pnt(*bptr);

  return 0;
}